<!--
 * @Author: zhuxiaoyi
 * @Date: 2023-05-18 15:32:44
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2023-08-06 20:59:31
 * @Description: 
-->
<template>
    <div class="display-container" :style="`height:${view.height}px`">
        <div class="display-inner">
            <el-menu :collapse="procesStore.menu.isCollapse" :default-active="state.activeIndex"
                class="el-menu-vertical-demo" @select="handleChange" :collapse-transition="false" background-color="#545c64"
                text-color="#fff" active-text-color="#ffd04b">
            </el-menu>
            <div class="dispaly-main">
                <el-row>
                    <el-col :span="24" class="bread-container">
                        <el-breadcrumb :separator-icon="ArrowRight">
                            <el-breadcrumb-item v-for="item in route.matched">{{ item.meta.title }}</el-breadcrumb-item>
                        </el-breadcrumb>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24" class="main-body" :style="`height:${view.height - 60}px`">
                        <el-row>
                            <el-col :span="24" style="display:flex;justify-content: space-between;padding-bottom: 15px;">
                                <div class="data-search-tit">用户管理</div>
                                <el-button size="small" type="primary" :icon="Plus">新建用户</el-button>
                            </el-col>
                        </el-row>
                        <el-table :data="users" size="small" style="width: 100%" :border="true">
                            <el-table-column type="index" width="80" />
                            <el-table-column prop="nickname" label="用户名" />
                            <el-table-column prop="username" label="账号" />
                            <el-table-column prop="id" label="用户id" />
                            <el-table-column prop="createDate" label="创建时间" />
                            <el-table-column prop="deptName" label="部门" />
                            <el-table-column prop="deptId" label="部门ID" />
                            <el-table-column fixed="right" label="操作" width="120">
                                <template #default>
                                    <el-button link type="primary" size="small" @click="">编辑</el-button>
                                    <el-button link type="danger" size="small">禁用</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-col>
                </el-row>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { ref, reactive, computed, watch } from 'vue'
import {
    Plus,
    Document,
    Menu as IconMenu,
    Location,
    Setting, ArrowRight, SuccessFilled, Operation
} from '@element-plus/icons-vue'
import * as _ from "lodash";
import { useUserStore } from "@/store/user"
import { useProcesStore } from '@/store/process'
import router from '@/router';
import HttpService from "@/api/api";
import { useRoute } from 'vue-router';
const userStore = useUserStore()
const procesStore = useProcesStore()
const route = useRoute()
var view = reactive({
    height: window.innerHeight - 61
})

let users = ref([])
const state: any = reactive({
    activeIndex: 'publish'
})
const getAllUsers = function () {
    let params = {

    };
    HttpService.user.getAllUsers(
        params,
        (res) => {
            if (res.status == 200) {
                res.data.data.users.forEach(user => {
                    users.value.push(user)
                });
            }
        },
        (error) => {
            console.log(error)
        }
    );
}

const handleChange = function (menu: string) {
    switch (menu) {
        case 'publish':
            router.push('/index/review/publish')
            break;
        default:
            break;
    }
}
getAllUsers()
window.onresize = _.debounce(() => {
    view.height = window.innerHeight - 61
}, 100)
</script>

<style lang="scss" scoped>
.display-inner {
    display: flex;


    .dispaly-main {
        padding: 15px;
        width: 100%;

        .bread-container {
            height: 30px;
        }

        .main-body {
            background: #fff;
            padding: 20px;
            box-sizing: border-box;
            box-shadow: 0px 12px 32px 4px rgba(0, 0, 0, .04), 0px 8px 20px rgba(0, 0, 0, .08);
            .data-search-tit {
                    font-size: 18px;
                    font-weight: 600;
                    font-family: "Courier New", Courier, monospace;
                }
        }
    }

}
</style>
<style lang="scss"></style>